﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.Data.Repositorios;
using CMS.Data.Classes;

namespace App.UI
{
    public partial class Login : System.Web.UI.Page
    {
        //Objs
        UsuarioRepository usuarioRepository = new UsuarioRepository();

        protected void Page_Load(object sender, EventArgs e)
        {
          
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            Usuario usuario = usuarioRepository.SelectByEmail(txtEmail.Text);

            if (usuario != null)
            {
                if (usuario.Senha == txtSenha.Text)
                //Login
                {
                    Session["User"] = usuario.Email;
                    Session["Password"] = usuario.Senha;
                    Response.Redirect("Default.aspx");
                }
                else
                {
                    lblNotFound.Visible = true;
                }
            }
        }
    }
}